<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Pro_ctrl extends CI_Controller {

	function __construct()
	{
		parent::__construct ();
		$this->load->model('usertype_model');
		$this->load->model('users_model');
		$this->load->library('form_validation');
		
	}
	
	function index() {
	
		$session_data = $this->session->userdata('logged_in');
		$usertype_id = $session_data["usertype_id"];
		$data['user'] = $this->users_model->select_profile($usertype_id);
		
		$this->load->view('adminsite/pro_view',$data);
	}
	
	function pro_user() {
		
		$session_data = $this->session->userdata('logged_in');
		$usertype_id = $session_data["usertype_id"];
		$data['user'] = $this->users_model->select_profile($usertype_id);
		
		$this->load->view('usersite/pro_view',$data);
	}
	
	function update_profile() {
		$usertype_id = $this->uri->segment(3);
		$username = $this->input->post('username');
		$password = md5($this->input->post('password'));
		$name = $this->input->post('name');
		$lastname = $this->input->post('lastname');
		$user_type = $this->input->post('hide_type');
		
		$data = array(
		'username' => $username,
		'password' => $password,
		'name' => $name,
		'lastname' => $lastname,
		'usertype_id' => $user_type
		);
		
		$this->users_model->update_data_user($data,$usertype_id);
		
		redirect('pro_ctrl', 'refresh');
	}

}